<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String basePath = request.getContextPath() + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<div class="wrapper wrapper-content">
	<div class="col-xs-12">
		<div class="ibox">
			<div class="ibox-content">
				<form name="FormPost" id="metastand-addOrUpdate-form"
					class="form-horizontal" method="post" action="" style="width: 100%">
					<!--操作类型  -->
					<input type="hidden" value="${type }" name="type">
					<!--主键  -->
					<input type="hidden"
						value="${empty metaStand?'':metaStand.stdMetaId }" name="stdMetaId">
					<div class="form-group">
						<label class="col-sm-4 control-label">字段名称:</label>
						<div class="col-sm-7">
                                <input type="text" name="stdMetaName" id="stdMetaName1" onkeyup="value=value.replace(/[\W]/g,'')"
									value="${empty metaStand?'':metaStand.stdMetaName }"
									class="form-control" datatype="*"  />
									<span style="font-family: Arial, Helvetica, sans-serif; color: #ff0000;" id="check"></span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">字段中文名称:</label>
						<div class="col-sm-7">
                                <input type="text" name="stdMetaChnName" id="stdMetaChnName"
                                	value="${empty metaStand?'':metaStand.stdMetaChnName }"
									class="form-control" datatype="*" nullmsg="字段中文名称!" required />
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">字段类型:</label>
						<div class="col-sm-7">
                                <input type="text" name="stdMetaType" id="stdMetaType" onkeyup="value=value.replace(/[^\a-\z\A-\Z0-9]/g,'')"
                                	value="${empty metaStand?'':metaStand.stdMetaType }"
									class="form-control" datatype="*" />
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">字段长度:</label>
						<div class="col-sm-7">
                                <input type="text" name="stdMetaLength" id="stdMetaLength" onkeyup="value=value.replace(/\D/g,'')"
                                	value="${empty metaStand?'':metaStand.stdMetaLength }"
									class="form-control" datatype="*" />
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">字段精度:</label>
						<div class="col-sm-7">
                                <input type="text" name="stdMetaPrecision" id="stdMetaPrecision" onkeyup="value=value.replace(/\D/g,'')"
                                	value="${empty metaStand?'':metaStand.stdMetaPrecision }"
									class="form-control" datatype="*" />
							
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">有效标识:</label>
						<div class="col-sm-7">
                                <%-- <input type="text" name="validFlag" id="validFlag"
                                	value="${empty metaStand?'':metaStand.validFlag }"
									class="form-control" datatype="*" /> --%>
								<select name="validFlag" id="validFlag" class="form-control" datatype="*" >
									<c:if test="${metaStand.validFlag ==1 || empty metaStand.validFlag}">
										<option value="1">是</option>
									</c:if>
									<c:if test="${metaStand.validFlag ==0 || empty metaStand.validFlag}">
										<option value="0">否</option>
									</c:if>
								</select>	
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<script>
//校验
$("#metastand-addOrUpdate-form").validate({
	rules : {
		stdMetaName : {
			required : true
		},
		stdMetaChnName : {
			required : true
		},
		stdMetaType : {
			required : true
		},
		stdMetaLength : {
			required : true
		},
		validFlag : {
			required : true
		}
	},
	messages : {
		stdMetaName : {
			required : "请输入字段名称"
		},
		stdMetaChnName : {
			required : "请输入字段中文名称",
		},
		stdMetaType : {
			required : "请输入字段类型",
		},
		stdMetaLength : {
			required : "请输入字段长度",
		},
		validFlag : {
			required : "请输入有效标识",
		}
	}, 
	ignore: ":hidden:not(.chosen-select)",
	submitHandler : function(form) {
		$("#metastand-addOrUpdate-form").ajaxSubmit({
			type : 'post',
			url : "<%=basePath%>rest/codemanager/metastand/saveOrEdit",
				success : function(data) {
					if (data.code == 1) {
						layer.open({
							type : 0,
							time : 800,
							icon : 1,
							content : data.msg,
							btn : 0,
							title : false,
							closeBtn : false,
							skin : 'layui-layer-rim',
							end : function() {
								layer.closeAll();
								//location.reload();
							}
						});
					} else {
						layer.msg(data.msg, {
							time : 2000,
							anim : 6
						});
					}
					var params = jQuery("#search-form").serializeJson();
					$("#table").bootstrapTable("refresh", {query: params});
				}
			});
		}
});

<%-- $('input#stdMetaName').change(function(){
	  var stdMetaName = $(this).val();
	  $.ajax({
	      async:false,//改为同步
	      type: "POST",
	      url: "<%=basePath%>rest/codemanager/metastand/onlyone",
	      data: {stdMetaName:stdMetaName},
	      dataType: "json",
	      success: function (result) {
	          if(result!=null){
	              $("#check").html("字段名称已存在！");
	              return false;
	          }
	      }
	  });
}); --%>

/* $(document).ready(function(){
	  $("#stdMetaLength").blur(function(){
	    var stdMetaLength = $("#stdMetaLength").val();
	    var re =/^[0-9]+$/;
	    if(!re.test(stdMetaLength)){
	    	alert("请输入正确的字段长度！")
	    	return false;
	    }
	  });
	});
	
 $(document).ready(function(){
	  $("#stdMetaPrecision").blur(function(){
	    var stdMetaPrecision = $("#stdMetaPrecision").val();
	    var re =/^[0-9]+$/;
	    if(!re.test(stdMetaPrecision)){
	    	alert("请输入正确的字段精度！")
	    	return false;
	    }
	  });
	});
	
$(document).ready(function(){
	  $("#stdMetaName1").blur(function(){
	    var stdMetaName1 = $("#stdMetaName1").val();
	    var re =/^[a-zA-Z0-9_]{0,}$/;
	    if(!re.test(stdMetaName1)){
	    	alert("请输入正确的字段名称！")
	    	return false;
	    }
	  });
	});
	
$(document).ready(function(){
	  $("#stdMetaType").blur(function(){
	    var stdMetaType = $("#stdMetaType").val();
	    var re =/^[0-9a-zA-Z]*$/g;
	    if(!re.test(stdMetaType)){
	    	alert("请输入正确的字段类型！")
	    	return false;
	    }
	  });
	}); */
</script>